import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'


Vue.use(VueRouter)
var beforeEnterfun = (to, from, next) => {
  let phone = window.localStorage.getItem("number");
  //判断是否登录
  if (!phone) {
    next("/LoginView")
    return;
  } else {
    next();
  }
}

const routes = [
  {
    path: '/',
    redirect: '/HomeView',
  },
  {
    path: '/HomeView',
    name: "HomeView",
    component: HomeView
  },
  
  {
    path: '/SettleMent',
    name: "SettleMent",
    component: () => import('../views/SettleMent.vue'),
    meta: {
      ShowAndHide: true
    }
  },


  {
    path: '/LibraryView',
    name: "LibraryView",
    component: () => import('../views/LibraryView.vue')
  },
  {
    path: '/DeskView',
    name: "DeskView",
    component: () => import('../views/DeskView.vue')
  },
  {
    path: '/CircleView',
    name: "CircleView",
    component: () => import('../views/CircleView.vue')
  },
  {
    path: '/MineView',
    name: "MineView",
    component: () => import('../views/MineView.vue'),

        //独享路由守卫
        beforeEnter: beforeEnterfun
  },
  {
    path: '/ShoppingCar',
    name: "ShoppingCar",
    component: () => import('../views/ShoppingCar.vue'),

     //独享路由守卫
     beforeEnter: beforeEnterfun,
    meta: {
      ShowAndHide: true
    }
  },
  {
    path: '/DetailView',
    name: "DetailView",
    component: () => import('../views/DetailView.vue'),
    meta: {
      ShowAndHide: true
    }
  },
  {
    path: '/Detail2View',
    name: "Detail2View",
    component: () => import('../views/Detail2View.vue'),
    meta: {
      ShowAndHide: true
    }
  },
  

  {
    path: '/OrderView',
    name: "OrderView",
    component: () => import('../views/OrderView.vue'),
    meta: {
      ShowAndHide: true
    }
  },


  {
    path: '/FindView',
    name: "FindView",
    component: () => import('../views/FindView.vue'),
    meta: {
      ShowAndHide: true
    }
  },

  {
    path: '/GratisDetall',
    name: "GratisDetall",
    component: () => import('../views/GratisDetall.vue'),
    meta: {
      ShowAndHide: true
    }
  },
  {
    path: '/Gratis2Detall',
    name: "Gratis2Detall",
    component: () => import('../views/Gratis2Detall.vue'),
    meta: {
      ShowAndHide: true
    }
  },
  {
    path: '/LoginView',
    name: "LoginView",
    component: () => import('../views/LoginView.vue'),
    meta: {
      ShowAndHide: true
    }
  },

  {
    path: '/ContentDetails',
    name: "ContentDetails",
    component: () => import('../views/ContentDetails.vue'),
    meta: {
      ShowAndHide: true
    },
      //独享路由守卫
      beforeEnter: beforeEnterfun
  },

  {
    path: '/CollectionView',
    name: "CollectionView",
    component: () => import('../views/CollectionView.vue'),
    meta: {
      ShowAndHide: true
    },
      //独享路由守卫
      beforeEnter: beforeEnterfun
  },






  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
